import { Injectable, NestInterceptor, CallHandler } from '@nestjs/common'
import { map } from 'rxjs/operators'
import {Observable} from 'rxjs'
 
// interface data<T>{
//     data:T
// }

type data<T> = {
    data: T
}
 
@Injectable()
export class FormatRes<T> implements NestInterceptor {
    intercept(context, next: CallHandler):Observable<data<T>> {
        return next.handle().pipe(map(data => {
            return {
               status: 0,
               success: true,
               message:"",
               ...data
            }
        }))
    }
}